<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">

$(function(){
	$("#findTitleBtn").click(function(){
		var title = $("#findTitle").val();
		
		if(title==""){
			alert("검색 제목을 입력해주세요");
			return;
		}else{
			//location.href="board.do?mode=findTitle&category=${param.category}&title="+title;
			$("#findForm").submit();
		}
	});
});



</script>


<c:choose>
	<c:when test="${param.category=='tip'||param.category=='notice_tip' }">
		<h3><b>Tip &amp; Tech</b></h3>
	</c:when>
	<c:otherwise>
		<h3><b>Free Board</b></h3>
	</c:otherwise>
</c:choose>
<table border="1" style="border-collapse: collapse; text-align: center; width:900px;">
	<thead>
	<tr>
	<th width="10%">번호</th>
	<th width="60%">제목</th>
	<th width="10%">작성자</th>
	<th width="10%">작성일</th>
	<th width="10%">조회수</th>
	</tr>
	</thead>
	<c:forEach var="bvo" items="${requestScope.bvo.list }">
		<tr align="center">
				<tr align="center">
				
		<!-- 공지사항관련 -->
			<c:choose>
				<c:when test="${bvo.category=='notice_tip'||bvo.category=='notice_free'}">
					<td>공지사항</td>
				</c:when>
				
				<c:otherwise>
					<td>${bvo.no }</td>
				</c:otherwise>
			</c:choose>
		<!-- 공지사항관련 끝 -->
			
		<!-- 댓글이 있으면 when 수행 없으면 otherwise 수행  -->		
			<c:choose>
				<c:when test="${bvo.re_count!=null}">
					<td>
						<a href="board.do?mode=content&no=${bvo.no }">${bvo.title }
						<font size="1" face="나눔 고딕"> [ ${bvo.re_count} ]</font></a>
					</td>
				</c:when>
				
				<c:otherwise>
					<td><a href="board.do?mode=content&no=${bvo.no }">${bvo.title }</a></td>
				</c:otherwise>
			</c:choose>
		<!-- 댓글관련 끝 -->	
			
			<td><a href="member.do?mode=friendMain&uid=${bvo.memberVO.uId }">${bvo.memberVO.nickname }</a></td>
			<td>${bvo.w_data }</td>
			<td>${bvo.count }</td>
		</tr>
	</c:forEach>

	
</table>
	<c:if test="${sessionScope.mvo!=null }">	
		<div style="text-align: center; width: 100px; height:30px; margin: 10px;">
		<p style="vertical-align: middle;"><a href="board.do?mode=view&page=write&category=${param.category }">글쓰기</a></p>
		</div>

		<div>
	
		<form action="board.do" method="post" id="findForm">
		<input type = "hidden" name = "mode" value="findTitle">
		<input type ="hidden" value ="${param.category}" name="category">	
			&nbsp;&nbsp;제목 검색 <input type = "text" id = "findTitle" name = "title">
		<input type = "button" id = "findTitleBtn" value = "검색">
		</form>
		</div>
	</c:if>

<!-- 페이즹 -->
<div id="paging" style="text-align: center;">
<c:if test="${requestScope.bvo.pagingBean.previousPageGroup }">
	<a href="board.do?mode=list&category=${param.category }&page=${requestScope.bvo.pagingBean.startPageOfPageGroup-1 }">
		<img src="${initParam.root }/img/left_arrow_btn.gif">
	</a>
</c:if>

<c:forEach var="ppg"
	begin="${requestScope.bvo.pagingBean.startPageOfPageGroup}"
	end="${requestScope.bvo.pagingBean.endPageOfPageGroup}">
	<c:choose>
		<c:when test="${requestScope.bvo.pagingBean.nowPage!=ppg}">
			<a href="board.do?mode=list&category=${param.category}&page=${ppg}">${ppg
				}</a>
		</c:when>
		<c:otherwise>
		   ${ppg}
	    </c:otherwise>
	</c:choose>
</c:forEach>

<c:if test="${requestScope.bvo.pagingBean.nextPageGroup }">
	<!-- 다음 그룹의 시작페이지 -->
	<a href="board.do?mode=list&category=${param.category}&page=${requestScope.bvo.pagingBean.endPageOfPageGroup+1 }">
		<img src="${initParam.root }/img/right_arrow_btn.gif">
	</a>
</c:if>
</div>